USE [Poll]
GO
/****** Object:  Table [dbo].[Users]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
	[ID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[email] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[UserProperties]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserProperties](
	[UserID] [uniqueidentifier] NOT NULL,
	[UserIdType] [int] NOT NULL,
	[IdentificationId] [nvarchar](50) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PollQuestion]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PollQuestion](
	[ID] [uniqueidentifier] NOT NULL,
	[Question] [nvarchar](2000) NOT NULL,
	[OwnerID] [uniqueidentifier] NOT NULL,
	[EndDate] [date] NULL,
 CONSTRAINT [PK_PollQuestion] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PollAnswer]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PollAnswer](
	[ID] [uniqueidentifier] NOT NULL,
	[QuestionID] [uniqueidentifier] NOT NULL,
	[Answer] [nvarchar](2000) NOT NULL,
	[OrderNumber] [int] NOT NULL,
 CONSTRAINT [PK_PollAnswer] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PollUserAnswerProperties]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PollUserAnswerProperties](
	[AnswerID] [uniqueidentifier] NOT NULL,
	[ip] [varchar](50) NULL,
	[sex] [bit] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PollUserAnswer]    Script Date: 02/14/2012 14:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PollUserAnswer](
	[UserID] [uniqueidentifier] NOT NULL,
	[AnswerID] [uniqueidentifier] NOT NULL,
	[UtcDateTime] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_PollAnswer_PollQuestion]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[PollAnswer]  WITH CHECK ADD  CONSTRAINT [FK_PollAnswer_PollQuestion] FOREIGN KEY([QuestionID])
REFERENCES [dbo].[PollQuestion] ([ID])
GO
ALTER TABLE [dbo].[PollAnswer] CHECK CONSTRAINT [FK_PollAnswer_PollQuestion]
GO
/****** Object:  ForeignKey [FK_PollQuestion_Users]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[PollQuestion]  WITH CHECK ADD  CONSTRAINT [FK_PollQuestion_Users] FOREIGN KEY([OwnerID])
REFERENCES [dbo].[Users] ([ID])
GO
ALTER TABLE [dbo].[PollQuestion] CHECK CONSTRAINT [FK_PollQuestion_Users]
GO
/****** Object:  ForeignKey [FK_PollUserAnswer_PollAnswer]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[PollUserAnswer]  WITH CHECK ADD  CONSTRAINT [FK_PollUserAnswer_PollAnswer] FOREIGN KEY([AnswerID])
REFERENCES [dbo].[PollAnswer] ([ID])
GO
ALTER TABLE [dbo].[PollUserAnswer] CHECK CONSTRAINT [FK_PollUserAnswer_PollAnswer]
GO
/****** Object:  ForeignKey [FK_PollUserAnswer_Users]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[PollUserAnswer]  WITH CHECK ADD  CONSTRAINT [FK_PollUserAnswer_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([ID])
GO
ALTER TABLE [dbo].[PollUserAnswer] CHECK CONSTRAINT [FK_PollUserAnswer_Users]
GO
/****** Object:  ForeignKey [FK_PollUserAnswerProperties_PollUserAnswer]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[PollUserAnswerProperties]  WITH CHECK ADD  CONSTRAINT [FK_PollUserAnswerProperties_PollUserAnswer] FOREIGN KEY([AnswerID])
REFERENCES [dbo].[PollAnswer] ([ID])
GO
ALTER TABLE [dbo].[PollUserAnswerProperties] CHECK CONSTRAINT [FK_PollUserAnswerProperties_PollUserAnswer]
GO
/****** Object:  ForeignKey [FK_UserProperties_Users]    Script Date: 02/14/2012 14:07:24 ******/
ALTER TABLE [dbo].[UserProperties]  WITH CHECK ADD  CONSTRAINT [FK_UserProperties_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([ID])
GO
ALTER TABLE [dbo].[UserProperties] CHECK CONSTRAINT [FK_UserProperties_Users]
GO
